package cn.sc.summer.redis.redisson.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author a-xin
 * @desc Redis连接方式
 * 包含:standalone-单节点部署方式
 * sentinel-哨兵部署方式
 * cluster-集群方式
 * masterslave-主从部署方式
 * @date 2019/6/20 下午4:21
 */
@Getter
@AllArgsConstructor
@SuppressWarnings("all")
public enum RedisConnectionTypeEnum {

    STANDALONE("standalone", "单节点部署方式","StandaloneConfigImpl"),
    SENTINEL("sentinel", "哨兵部署方式", "SentinelConfigImpl"),
    CLUSTER("cluster", "集群方式", "ClusterConfigImpl"),
    MASTER_SLAVE("masterSlave", "主从部署方式", "MasterSlaveConfigImpl");

    private final String type;
    private final String desc;
    private final String clazz;

    public static RedisConnectionTypeEnum getByType(String type) {
        if (StrUtil.isBlank(type)) {
            return null;
        }
        for (RedisConnectionTypeEnum enums : RedisConnectionTypeEnum.values()) {
            if (enums.type.equals(type)) {
                return enums;
            }
        }
        return null;
    }

}
